#include"SkyDome.h"
#include"Scene.h"

void SkyDome::Render()
{
	position = scene.mainCamera.position;

	D3DDevice->SetRenderState(D3DRS_LIGHTING, false);

	D3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	D3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

	D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
	D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);

	D3DDevice->SetTransform(D3DTS_WORLD, &(LocalToWorldMatrix()));
	D3DDevice->SetTransform(D3DTS_VIEW, &(scene.mainCamera.ViewMatrix()));
	D3DDevice->SetTransform(D3DTS_PROJECTION, &(scene.mainCamera.ProjMatrix()));
	D3DDevice->SetStreamSource(0, vertexBuffer, 0, 20);
	D3DDevice->SetFVF(VertexUV::FVF);
	D3DDevice->SetIndices(indexBuffer);
	D3DDevice->SetTexture(0, skyTex);

	D3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, numVertices, 0, numTriangles);
	//printf("numVerts:%d\nnumTris:%d\n", numVertices, numTriangles);
}